package com.example.springbootstudy.Ui.Impl;

import com.example.springbootstudy.Ui.DeptUi;
import com.example.springbootstudy.pojo.Dept;
import com.example.springbootstudy.pojo.Result;
import com.example.springbootstudy.service.Impt.AddDeptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*@Controller
@ResponseBody*/
//寻找业务逻辑层
@RestController
public class DeptUiImpl implements DeptUi {
    //自动装配 @Autowired
    @Autowired
    AddDeptServiceImpl addDeptService;
    @GetMapping("/addInfo")
    @Override
    public String addUi(String ask) {
        String s = addDeptService.addDeptService("用户来请求啦");
        //寻找业务逻辑层
        return s;
    }
    @GetMapping("/dept")
    public Result list(){
        return Result.success(addDeptService.selectAllService());
    }
    @DeleteMapping("/dept/{id}")
    public Result delete(@PathVariable Integer id){
        addDeptService.deleteAllService(id);
        return Result.success();
    }
    @PostMapping("dept")
    public Result insert(@RequestBody Dept dept){
        addDeptService.insertAllSarvice(dept);
        return Result.success();
    }
}
